<meta charset="UTF-8">
<?php
ini_set('max_execution_time', '0');
ini_set('memory_limit','512M');
$sql = '';
$log_file = './file/log.txt';
$put_file = "exec".date('Ymd_H_i_s').".sql";
$txt = file_get_contents($log_file);
// $dataArr = nl2br($txt);
$dataArr = explode("\n",$txt);
$codeArr = array (
		'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' 
);
if(!$handle = fopen($put_file,'a+')){
   echo '文件打开失败;';
   exit;
}
foreach($dataArr as $val){
	$value = explode(" ",$val);
	$randNum = mt_rand(0,9);
	$codeKey = mt_rand(0,25);
    $time = mt_rand(1380000000,1389999999);
    $sql = 'insert into sina_poiiod_all (code,rand_num,history_id,new_id,createtime) VALUES ';
    $sql .= "('".$codeArr[$codeKey]."',".$randNum.",'".$value[0]."','".$value[1]."',".$time.");\n";
    if(fwrite($handle,$sql) === FALSE){
    	echo "写入SQL：< ".$sql.' >失败;';
    	exit;
    }
    echo $sql;
    echo "<br>";
}
fclose($handle);

// dump($sql);
function dump($result = array()){
	echo "<pre>";
	print_r($result);
}